package com.hpq.user.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 角色枚举
 */
@Getter
@AllArgsConstructor
public enum RoleEnum {
    ADMIN(1L,"超级管理员"),
    CHAT_MANAGER(2L,"聊天管理员");
    private final Long id;
    private final String role;
    private static Map<Long,RoleEnum> cache;
    static{
        cache = Arrays.stream(RoleEnum.values()).collect(Collectors.toMap(RoleEnum::getId, Function.identity()));
    }
    public static RoleEnum of(Long id){
        return cache.get(id);
    }

}
